package com.cosina.game.crystallight.ui.battle.drawable;

import android.graphics.Canvas;
import android.graphics.Point;

import com.cosina.game.crystallight.engine.BattleEngine;
import com.cosina.game.crystallight.engine.Architect;
import com.cosina.game.crystallight.model.crystal.Tower;
import com.cosina.game.crystallight.ui.battle.BattleResource;
import com.cosina.game.crystallight.ui.battle.drawadapter.BaseDrawable;
import com.cosina.game.crystallight.ui.common.PaintSuite;

public class BuildDrawable extends BaseDrawable{

	@Override
	public void draw(Canvas canvas) {
		drawTower(canvas);
		drawPuddle(canvas);
	}
	public static final int PUDDLE_SPAN_X = 7, PUDDLE_SPAN_Y = 7;
	
	private void drawPuddle(Canvas canvas) {
		Architect builderManager = BattleEngine.architect;
		for(Point point : builderManager.getPuddleLocations()){
			canvas.drawBitmap(BattleResource.puddle, 
					point.x * 44 + PUDDLE_SPAN_X + getXSpan(), 
					point.y *44 + PUDDLE_SPAN_Y + getYSpan(), 
					PaintSuite.p4Simple);
		}
	}

	private void drawTower(Canvas canvas) {
		Architect builderManager = BattleEngine.architect;
		for(Tower each : builderManager.getTowers()){
			canvas.drawBitmap(BattleResource.tower, 
					each.location.x * 44 + getXSpan(), 
					each.location.y *44 + getYSpan(), 
					PaintSuite.p4Simple);
		}
	}
	
	public int getXSpan(){
		return 5;
	}
	
	public int getYSpan(){
		return 5;
	}
}
